// Class for characters with animations
//
// Nick Kitten
// 2009

#pragma once

#include "TexturedObj.h"
#include "Animation.h"
#include "Pathfinder.h"
#include "PathTraverser.h"
#include "Grid.h"

using namespace std;

class Agent: public TexturedObj
{
public:
	enum State{ Walking, Idle, Attacking, Fleeing };

	Agent( char * fileName, int id, Pathfinder & pather, Grid<char> & occGrid,
		float walkSpeed = .4, float turnSpeed = .4 );
	virtual ~Agent();


	State getState() const;						// return the state of this object
	void setState(State s);								// set the state of the object
	void addAnimation( Animation::Action action, char * fileName, int speed = 100, 
		bool loopable = false, bool velocityDependent = false );
	void playAnimation( Animation::Action action );
	void stopAnimation();
	void setInterpolation( int interp );
	void moveTo( Triple goal ); 
	void setWalkSpeed( float newSpeed );
	void setTurnSpeed( float newSpeed );
	virtual void update();

protected:
	// current running speed used to scale animation playback
	float speed;
	static const int maxAnimations = 10;
	Animation animations[maxAnimations];
	Pathfinder & pathfinder;
	list<Triple> currPath;
	PathTraverser traverser;
	Pose newPose;
	Pose oldPose;
	State oldState;
	State state;		// State of this object.
	bool changedState;
	Grid<char> & occGrid;

};